package com.zjl.media.core;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker;
import lombok.Builder;
import lombok.Data;

import java.io.ByteArrayOutputStream;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;

/**
 * Created on 2021-10-26 15:42:39
 *
 * @author linfuxin
 */
@Data
public abstract class MediaTransferContext {

    protected String rtsp;

    /**
     * 播放视频的所有ws客户端
     */
    protected CopyOnWriteArrayList<ChannelHandlerContext> clients;

    /**
     * 将要推送给ws客户端的视频流
     */
    protected ByteArrayOutputStream output;

    /**
     * 缓存flv视频首帧，新添加ws客户端不发送首帧会导致不能播放
     */
    protected byte[] header;

    /**
     * 控制mediaManager与MediaTransferTask写入header异步问题
     */
    protected CountDownLatch headerLatch;

}
